<?php
/**
 * Created by PhpStorm.
 * User: JackWang
 * Date: 2022/4/26
 * Time: 17:57
 */

//require "./vendor/autoload.php";
use PHPUnit\Framework\TestCase;

class StackTest extends TestCase
{
    /*
    public function testPushAndPop()
    {
        $stack = [];
        $this->assertEquals(0, count($stack));

        array_push($stack, 'foo');
        $this->assertEquals('foo', $stack[count($stack) - 1]);
        $this->assertEquals(1, count($stack));

        $this->assertEquals('foo', array_pop($stack));
        $this->assertEquals(0, count($stack));
    }
*/
    public function testEmpty()
    {
        $stack = [];
        $this->assertEmpty($stack);
        return $stack;
    }

    /**
     * @depends testEmpty
     */
    public function testPush(array $stack)
    {
//        array_push($stack, 'foo1');
        array_push($stack, 'foo');
        $this->assertEquals('foo', $stack[count($stack) - 1]);
        $this->assertNotEmpty($stack);
        return $stack;
    }

    /**
     * @depends testPush
     */
    public function testPop(array $stack)
    {
        $this->assertEquals('foo',array_pop($stack));
        $this->assertEmpty($stack);
    }
}
